package com.cauli.file.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cauli.file.mapper.ShareMapper;
import com.cauli.file.model.dto.share.ShareListDTO;
import com.cauli.file.model.entity.Share;
import com.cauli.file.model.vo.share.ShareListVO;
import com.cauli.file.service.ShareService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Cauli
 * @date 2023-03-20 12:00
 * @description 分享 服务实现类
 */
@Slf4j
@Service
@Transactional(rollbackFor=Exception.class)
public class ShareServiceImpl extends ServiceImpl<ShareMapper, Share> implements ShareService {
    @Override
    public List<ShareListVO> selectShareList(ShareListDTO shareListDTO, Long userId) {
        Long beginCount = (shareListDTO.getPageNum() - 1) * shareListDTO.getPageSize();
        return baseMapper.selectShareList(shareListDTO.getShareFilePath(), shareListDTO.getShareBatchNum(), beginCount, shareListDTO.getPageSize(), userId);
    }

    @Override
    public Long selectShareListTotalCount(ShareListDTO shareListDTO, Long userId) {
        return baseMapper.selectShareListTotalCount(shareListDTO.getShareFilePath(), shareListDTO.getShareBatchNum(), userId);
    }
}
